package com.cjj.common.enums;


/**
 * 商品成色枚举
 */
public enum ProductCondition {
    BRAND_NEW("全新"),
    LIKE_NEW("九五新"),
    EXCELLENT("九成新"),
    VERY_GOOD("八五新"),
    GOOD("七成新"),
    FAIR("五成新");

    private final String value;

    ProductCondition(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    /**
     * 通过值查找枚举
     */
    public static ProductCondition fromValue(String value) {
        for (ProductCondition condition : values()) {
            if (condition.getValue().equals(value)) {
                return condition;
            }
        }
        throw new IllegalArgumentException("未知的商品成色: " + value);
    }

    /**
     * 获取所有可选值
     */
    public static String[] getAllValues() {
        ProductCondition[] conditions = values();
        String[] values = new String[conditions.length];
        for (int i = 0; i < conditions.length; i++) {
            values[i] = conditions[i].getValue();
        }
        return values;
    }

    @Override
    public String toString() {
        return value;
    }
}